package org.hljdrl.daf;

import org.hljdrl.daf.ft.MyPagerAdapter;
import org.hljdrl.daf.json.JavaToGJsonTest;
import org.hljdrl.daf.json.JavaToJsonTest;
import org.hljdrl.daf.protobuf.JavaToProtobufTest;
import org.hljdrl.daf.test.TestManager;
import org.hljdrl.daf.xml.JavaToXmlTest;

import android.os.Bundle;
import android.support.v4.view.ViewPager;
import android.util.TypedValue;

import com.astuetz.viewpager.extensions.PagerSlidingTabStrip;

public class HomeActivity extends BaseActivity {

	private PagerSlidingTabStrip tabs;
	private ViewPager pager;
	private MyPagerAdapter adapter;

	private TestManager mTestManager = TestManager.get();

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.root_home);

		tabs = (PagerSlidingTabStrip) findViewById(R.id.tabs);
		pager = (ViewPager) findViewById(R.id.pager);
		mTestManager.clearList();
		
		mTestManager.addModuleTest(new JavaToXmlTest(this));
		mTestManager.addModuleTest(new JavaToJsonTest(this));
		mTestManager.addModuleTest(new JavaToGJsonTest(this));
		mTestManager.addModuleTest(new JavaToProtobufTest(this));

		adapter = new MyPagerAdapter(getSupportFragmentManager(),
				mTestManager.getModuleTestList());
		pager.setAdapter(adapter);
		final int pageMargin = (int) TypedValue.applyDimension(
				TypedValue.COMPLEX_UNIT_DIP, 4, getResources()
						.getDisplayMetrics());
		pager.setPageMargin(pageMargin);
		pager.setMinimumHeight(3);
		tabs.setViewPager(pager);
		getActivityHelper().setActionBarTitle("DataAutoFormat");
	}

}
